﻿@model ProductModel

@if (Model.Id == 0)
{
    <p class="text-muted">
        @T("Admin.Catalog.Products.BundleItems.SaveBeforeEdit")
    </p>
    return;
}

<div class="alert alert-info alert-dismissible">
    <div>
        @T("Admin.Catalog.Products.BundleItems.NotesOnProductBundles"):
        <a class="ml-2" id="ProductBundleInfoLink" href="javascript:void(0)" data-in="@T("Common.Show")" data-out="@T("Common.Hide")">@T("Common.Show")</a>
    </div>
    <div id="ProductBundleInfoContainer" class="hide">
        @Html.Raw(T("Admin.Catalog.Products.BundleItems.AdminNoteGeneral"))

        @Html.Raw(T(Model.BundlePerItemPricing ? "Admin.Catalog.Products.BundleItems.AdminNotePerItemPricing" : "Admin.Catalog.Products.BundleItems.AdminNoteBundlePricing"))

        @if (Model.BundlePerItemShipping)
        {
            @Html.Raw(T("Admin.Catalog.Products.BundleItems.AdminNotePerItemShipping"))
        }
    </div>
    <button type="button" class="btn-close" data-dismiss="alert"></button>
</div>

@(Html.LocalizedEditor<ProductModel, ProductLocalizedModel>("product-bundle-localized",
    @<text>
        <div class="adminContent">
            <div class="adminRow">
                <div class="adminTitle">
                    <smart-label asp-for="Locales[item].BundleTitleText" />
                </div>
                <div class="adminData">
				    @*IMPORTANT: Do not delete, this hidden element contains the id to assign localized values to the corresponding language *@
                    <input asp-for="Locales[item].LanguageId" type="hidden" />
                    <input asp-for="Locales[item].BundleTitleText" />
                    <span asp-validation-for="Locales[item].BundleTitleText"></span>
                </div>
            </div>
        </div>
    </text>
    ,
    @<text>
        <div class="adminContent">
            <div class="adminRow">
                <div class="adminTitle">
                    <smart-label asp-for="BundleTitleText" />
                </div>
                <div class="adminData">
                    <input asp-for="BundleTitleText" />
                    <span asp-validation-for="BundleTitleText"></span>
                </div>
            </div>
        </div>
    </text>
))

<div class="adminContent">
    <div class="adminRow">
        <div class="adminTitle">
            <smart-label asp-for="BundlePerItemPricing" />
        </div>
        <div class="adminData">
            <input asp-for="BundlePerItemPricing" />
            <span asp-validation-for="BundlePerItemPricing"></span>
        </div>
    </div>
    <div class="adminRow">
        <div class="adminTitle">
            <smart-label asp-for="BundlePerItemShipping" />
        </div>
        <div class="adminData">
            <input asp-for="BundlePerItemShipping" />
            <span asp-validation-for="BundlePerItemShipping"></span>
        </div>
    </div>
    <div class="adminRow">
        <div class="adminTitle">
            <smart-label asp-for="BundlePerItemShoppingCart" />
        </div>
        <div class="adminData">
            <input asp-for="BundlePerItemShoppingCart" />
            <span asp-validation-for="BundlePerItemShoppingCart"></span>
        </div>
    </div>
</div>

@{
    var gridViewData = new ViewDataDictionary(this.ViewData);
    @if (Model.Id > 0)
    {
        gridViewData["Parent"] = Model;
    }
}

<partial name="Grids/_Grid.BundleItems" model="null" view-data="gridViewData" />

<script>
    // Toggle bundle infos.
    $(document).on('click', '#ProductBundleInfoLink', function () {
        var $el = $(this);
        var info = $('#ProductBundleInfoContainer');
        $el.text($el.attr(info.is(':visible') ? 'data-in' : 'data-out'));
        info.slideToggle(200);
    });
</script>